<?php
namespace app\fsadmin\controller;

use think\Controller;

class MenuController extends BaseController
{
    private $menu_l;

    public function _initialize()
    {
        parent::_initialize();
        $this->menu_l = model('MenuLogic', "logic");
    }

    public function index()
    {
        if ($this->request->isAjax()) {
            $rs['data']['list'] = $this->menu_l->getAdminEditList();
            $rs['status']       = 200;
            ajax_return($rs);
        }
        return $this->fetch();

    }

    public function savemenu()
    {
        if ($this->request->isAjax()) {
            $data = $this->request->except("level");
            $rs   = $this->menu_l->saveMenu($data);
            model("log")->saveLog(["content"=>"更新栏目信息","datas"=>serialize($data)]);
            ajax_return($rs);
        }
    }

    public function delmenu()
    {
        if ($this->request->isAjax()) {
            $params = $this->request->only("id");
            $rs     = $this->menu_l->delMenu($params['id']);
            model("log")->saveLog(["content"=>"删除栏目信息","datas"=>serialize($params['id'])]);
            ajax_return($rs);
        }
    }

}
